<!--包含头部文件-->
{include file="public/header" /}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>运营管理 <span class="c-gray en">&gt;</span> 专题管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-10">
        <span class="l">
            <a href="javascript:;" onclick="subject_add('新增专题','{:url(\'operate/subject_add\')}',800,600)" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 新增专题</a>
        </span>
    </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="13">专题列表</th>
        </tr>
        <tr class="text-c">
            <!--<th width="25"><input type="checkbox" name="" value=""></th>-->
            <th>封面</th>
            <th>专题名称</th>
            <th>所属banner</th>
            <th>专题文案</th>
            <th>商品数</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach name="list" item="v"}
        <tr class="text-c">
            <td>
                <img src="{$v.cover_img}" width="336" height="80">
            </td>
            <td>{$v.name}</td>
            <td>{$v.bannerid}</td>
            <td>{$v.desc}</td>
            <td>{$v.name}</td>
            <td>{$v.begin_time|date='Y-m-d H:i:s',###}</td>
            <td>{$v.end_time|date='Y-m-d H:i:s',###}</td>
            <td>{$v.add_time|date='Y-m-d H:i:s',###}</td>
            <td class="td-manage">
                <a title="编辑" href="javascript:;" onclick="subject_edit('编辑','{:url(\'operate/subject_edit\',[\'subject_id\'=>$v.subject_id])}','800','600')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a title="关联商品" href="javascript:;" onclick="subject_items('关联商品','{:url(\'operate/subject_items\',[\'subject_id\'=>$v.subject_id])}',$(window).width(),$(window).height())" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe667;</i></a>
                <a title="删除" href="javascript:;" onclick="subject_del(this,'{$v.subject_id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
            </td>
        </tr>
        {/foreach}
        <tr>
            <td colspan="9" align="left">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;排序&nbsp;&nbsp;">
            </td>
        </tr>
        </tbody>
    </table>
    <div class="row">
        <div class="col-sm-2" id="pageBox">
            {$page}
        </div>
    </div>
</div>
<!--包含footer文件-->
{include file="public/footer" /}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*管理员-增加*/
    function subject_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*专题-编辑*/
    function subject_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*专题-编辑*/
    function subject_items(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*专题-删除*/
    function subject_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '{:url("operate/subject_del")}',
                data:{"subject_id":id},
                dataType: 'json',
                success: function(data){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

    /*管理员-编辑*/
    function goods_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }

    $(function () {
        $(".tuijian").bind("change",function(){
            var tuijian = $(this).val();
            var id = this.dataset.id;
            $.ajax({
                type: 'POST',
                url: '{:url("operate/set_tuijian")}',
                data:{"id":id,"tuijian":tuijian},
                dataType: 'json',
                success: function(data){
                    if (data.code=200){
                        layer.msg('设置成功!',{icon:1,time:1000});
                    }else {
                        layer.alert('设置失败'+data.msg+'',{
                            skin: 'layui-layer-molv' //样式类名 自定义样式
                            ,closeBtn: 0  // 是否显示关闭按钮
                            ,anim: 1 //动画类型
                            ,btn: '确认'//按钮
                            ,icon: 6  // icon
                        })
                    }

                },
                error:function(data) {
                    layer.alert('请求失败',{
                        skin: 'layui-layer-molv' //样式类名 自定义样式
                        ,closeBtn: 0  // 是否显示关闭按钮
                        ,anim: 1 //动画类型
                        ,btn: '确认'//按钮
                        ,icon: 6  // icon
                    })
                },
            });
        });
    })


</script>
</body>
</html>